/*
 * @Author: szx
 * @Date: 2022-03-19 12:25:40
 * @LastEditTime: 2022-03-19 12:43:36
 * @Description:
 * @FilePath: \leetcode\剑指offer\15\15.js
 */
/**
 * @param {number} n - a positive integer
 * @return {number}
 */
var hammingWeight = function (n) {
    let res = 0;
    while (n) {
        n &= n - 1;
        res++;
    }
    return res;
};
